uniform float4x4 StateComplete;
sampler2D tex0;
sampler2D tex1;
float texelSize = 1.0/256.0;
float amp = 2;
float4 edgeColor = { 0, 0, 0, 1 };
float4 bgColor = { 1, 1, 1, 1 };

void vsMain(
			in float4 pos: POSITION, 
			out float4 opos: POSITION, 
			in float2 tc: TEXCOORD, 
			out float2 otc: TEXCOORD)
{
	opos = mul(StateComplete, pos);
	otc = tc;
}

float4 psMain(in float2 t: TEXCOORD): COLOR
{
	float d = length(tex2D(tex0, t));
	float dx = length(tex2D(tex0, t+float2(texelSize,0)))-d;
	float dy = length(tex2D(tex0, t+float2(0,texelSize)))-d;
	float a = (abs(dx)+abs(dy)) * amp;
	return bgColor * clamp(1-a, 0,1) + edgeColor * a;
}